/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sparrsonat;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author leofidjeland
 */
public class NodeSimulator extends Thread {
    
    private final TimeMachine timeMachine;
    private final int sleepTime = 100;
    private double prob = 0.2;

    NodeSimulator(TimeMachine timeMachineIn) {
        timeMachine = timeMachineIn;
    }
    
    @Override
    public void run(){
        while(true){
            try {
                if(prob > Math.random()){
                    timeMachine.report();
                }
                Thread.sleep(sleepTime);
            } catch (InterruptedException ex) {
                Logger.getLogger(NodeSimulator.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
}
